<?php
/**
 * @Author:      zk
 * @DateTime:    18-6-7 上午11:39
 * @Description: 车架号匹配信息
 */
class DataCarVinInfo extends Eloquent
{
    protected $connection   = 'mysql_data';
    protected $table        = 'car_vin_info';
    protected $primaryKey   = 'vin';    //主键 车架号
    
    /**
     * @Author:      zk
     * @DateTime:    18-6-8 下午3:15
     * @Description: 添加、编辑 车架号匹配信息
     * @param string    $vin       车架号
     * @param array     $data       参数数组 [key为数据表中定义字段名称]
     * @return boolean
     */
    public static function setupVinInfo($vin, $data) {
        if(!is_array($data)){
            return FALSE;
        }
        $info = DataCarVinInfo::where('vin', $vin)->first();
        if($info){
            $info->updated_at = date('Y-m-d H:i:s', time());
        } else {
            $info = new DataCarVinInfo();
            $info->vin = $vin;
            $info->created_at = date('Y-m-d H:i:s', time());
        }
        if(isset($data['bandEnName'])){
            $info->bandEnName = $data['bandEnName'];    //品牌英文
        }
        if(isset($data['bodyForm'])){
            $info->bodyForm = $data['bodyForm'];        //车身形式
        }
        if(isset($data['brakeType'])){
            $info->brakeType = $data['brakeType'];        //制动类型
        }
        if(isset($data['brandName'])){
            $info->brandName = $data['brandName'];        //品牌
        }
        if(isset($data['country'])){
            $info->country = $data['country'];        //国家
        }
        if(isset($data['countryId'])){
            $info->countryId = $data['countryId'];        //国家id
        }
        if(isset($data['cylinderArrangement'])){
            $info->cylinderArrangement = $data['cylinderArrangement'];        //气缸排列形式
        }
        if(isset($data['cylinderVolume'])){
            $info->cylinderVolume = $data['cylinderVolume'];        //气缸容积
        }
        if(isset($data['cylindersNumber'])){
            $info->cylindersNumber = $data['cylindersNumber'];        //发动机缸数
        }
        if(isset($data['doorNumber'])){
            $info->doorNumber = $data['doorNumber'];        //车门数
        }
        if(isset($data['driveForm'])){
            $info->driveForm = $data['driveForm'];        //驱动形式
        }
        if(isset($data['eVehicleSystem'])){
            $info->eVehicleSystem = $data['eVehicleSystem'];        //电商车系
        }
        if(isset($data['emissionStandars'])){
            $info->emissionStandars = $data['emissionStandars'];        //排放标准
        }
        if(isset($data['engineDesc'])){
            $info->engineDesc = $data['engineDesc'];        //发动机描述
        }
        if(isset($data['engineJetType'])){
            $info->engineJetType = $data['engineJetType'];        //发动机喷射类型
        }
        if(isset($data['engineType'])){
            $info->engineType = $data['engineType'];        //发动机类型
        }
        if(isset($data['exhaustVolume'])){
            $info->exhaustVolume = $data['exhaustVolume'];        //排量
        }
        if(isset($data['exhaustVolumeTrans'])){
            $info->exhaustVolumeTrans = $data['exhaustVolumeTrans'];        //排量+变速器
        }
        if(isset($data['fileNumber'])){
            $info->fileNumber = $data['fileNumber'];        //档位数
        }
        if(isset($data['firstLetterBand'])){
            $info->firstLetterBand = $data['firstLetterBand'];        //车型品牌首字母
        }
        if(isset($data['floorNo'])){
            $info->floorNo = $data['floorNo'];        //底盘号
        }
        if(isset($data['frontSuspedSys'])){
            $info->frontSuspedSys = $data['frontSuspedSys'];        //前悬挂系统
        }
        if(isset($data['frontTireSpec'])){
            $info->frontTireSpec = $data['frontTireSpec'];        //前轮胎规格
        }
        if(isset($data['frontTread'])){
            $info->frontTread = $data['frontTread'];        //前轮距
        }
        if(isset($data['fuelTag'])){
            $info->fuelTag = $data['fuelTag'];        //燃油标号
        }
        if(isset($data['fuelTankCapacity'])){
            $info->fuelTankCapacity = $data['fuelTankCapacity'];        //油箱容积
        }
        if(isset($data['fuelType'])){
            $info->fuelType = $data['fuelType'];        //燃油类型
        }
        if(isset($data['hubSpec'])){
            $info->hubSpec = $data['hubSpec'];        //轮毂规格
        }
        if(isset($data['length'])){
            $info->length = $data['length'];        //长
        }
        if(isset($data['madeYear'])){
            $info->madeYear = $data['madeYear'];        //生产年份
        }
        if(isset($data['manufacturerEnName'])){
            $info->manufacturerEnName = $data['manufacturerEnName'];        //厂家英文名称
        }
        if(isset($data['manufacturerName'])){
            $info->manufacturerName = $data['manufacturerName'];        //厂家名称
        }
        if(isset($data['mid'])){
            $info->mid = $data['mid'];
        }
        if(isset($data['mids'])){
            $info->mids = $data['mids'];
        }
        if(isset($data['modelNickName'])){
            $info->modelNickName = $data['modelNickName'];        //车型俗称
        }
        if(isset($data['nid'])){
            $info->nid = $data['nid'];
        }
        if(isset($data['onMarketMonth'])){
            $info->onMarketMonth = $data['onMarketMonth'];        //上市月份
        }
        if(isset($data['onMarketYear'])){
            $info->onMarketYear = $data['onMarketYear'];        //上市年份
        }
        if(isset($data['pakingModel'])){
            $info->pakingModel = $data['pakingModel'];        //驻车刹车类型
        }
        if(isset($data['pbid'])){
            $info->pbid = $data['pbid'];
        }
        if(isset($data['powerSpeed'])){
            $info->powerSpeed = $data['powerSpeed'];        //功率/转速
        }
        if(isset($data['powerSteering'])){
            $info->powerSteering = $data['powerSteering'];        //转向助力精简
        }
        if(isset($data['powerSteeringType'])){
            $info->powerSteeringType = $data['powerSteeringType'];        //转向助力类型
        }
        if(isset($data['price'])){
            $info->price = $data['price'];        //厂商指导价
        }
        if(isset($data['rearSuspedSys'])){
            $info->rearSuspedSys = $data['rearSuspedSys'];        //后悬挂系统
        }
        if(isset($data['rearTireSpec'])){
            $info->rearTireSpec = $data['rearTireSpec'];        //后轮胎规格
        }
        if(isset($data['rearTread'])){
            $info->rearTread = $data['rearTread'];        //后轮距
        }
        if(isset($data['salesVersion'])){
            $info->salesVersion = $data['salesVersion'];        //销售版本
        }
        if(isset($data['sbid'])){
            $info->sbid = $data['sbid'];
        }
        if(isset($data['seatNumber'])){
            $info->seatNumber = $data['seatNumber'];        //座位数
        }
        if(isset($data['sid'])){
            $info->sid = $data['sid'];        //车系id
        }
        if(isset($data['stopProductionYear'])){
            $info->stopProductionYear = $data['stopProductionYear'];        //停产年份
        }
        if(isset($data['torqueSpeed'])){
            $info->torqueSpeed = $data['torqueSpeed'];        //扭矩/转速
        }
        if(isset($data['transmissionDesc'])){
            $info->transmissionDesc = $data['transmissionDesc'];        //变速器描述
        }
        if(isset($data['vehicleCategory'])){
            $info->vehicleCategory = $data['vehicleCategory'];        //车辆类型
        }
        if(isset($data['vehicleSystem'])){
            $info->vehicleSystem = $data['vehicleSystem'];        //车系
        }
        if(isset($data['vehicleSystemEn'])){
            $info->vehicleSystemEn = $data['vehicleSystemEn'];        //车系英文
        }
        if(isset($data['vehicleTypeName'])){
            $info->vehicleTypeName = $data['vehicleTypeName'];        //车型名称
        }
        if(isset($data['vinYear'])){
            $info->vinYear = $data['vinYear'];        //VIN年份
        }
        if(isset($data['wheelbase'])){
            $info->wheelbase = $data['wheelbase'];        //轴距
        }
        if(isset($data['width'])){
            $info->width = $data['width'];        //宽
        }
        if(isset($data['year'])){
            $info->year = $data['year'];        //年款
        }
        if(isset($data['status'])){
            $info->status = $data['status'];        //状态 [0:删除;1:正常;]
        }
        
        return $info->save();
    }
    
    
}